﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using Fayshine.VA.ViewModels;

namespace Fayshine.VA.Views.SysConfig
{
    public partial class Role : Page
    {
        private UserRoleViewModel m_ViewModel = null;

        public Role()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(Role_Loaded);
        }

        void Role_Loaded(object sender, RoutedEventArgs e)
        {
            m_ViewModel = new UserRoleViewModel();
            this.DataContext = m_ViewModel;

            m_ViewModel.GetAllRoles();
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void cmbRoles_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (m_ViewModel != null)
            {
                if (cmbRoles.SelectedIndex == 1)
                {
                    m_ViewModel.ResetSelectRole(2);
                }
                else if (cmbRoles.SelectedIndex == 2)
                {
                    m_ViewModel.ResetSelectRole(3);
                }
                else
                {
                    m_ViewModel.ResetSelectRole(1);
                }
            }
        }

    }
}
